package com.haoshuang.zhouzhoubang.ui.page.mine.contract

import android.content.Context
import android.os.Bundle
import android.widget.ImageView
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ActivityMyContractBinding
import com.haoshuang.zhouzhoubang.ui.adapter.ViewPagerAdapter
import com.haoshuang.zhouzhoubang.ui.page.mine.contract.add.AddContractActivity
import com.haoshuang.zhouzhoubang.ui.page.mine.contract.fragment.MyContractChildFragment
import com.lnkj.jialubao.utils.AccountUtils
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.ImageViewerPopupView
import com.lxj.xpopup.interfaces.OnSrcViewUpdateListener
import com.lxj.xpopup.util.SmartGlideImageLoader
import com.mufeng.libs.base.BaseVMActivity
import com.mufeng.libs.core.setOnItemClick
import com.mufeng.libs.utils.startPage
import com.mufeng.libs.utils.startPageForResult
import com.mufeng.libs.utils.view.click
import com.mufeng.libs.utils.view.clickWithTrigger
import com.mufeng.libs.utils.view.vertical


/**
 *  我的合同
 */
class MyContractActivity : BaseVMActivity<MyContractViewModel, ActivityMyContractBinding>() {

    companion object {
        fun launch(context: Context) {
            context.startPage<MyContractActivity>()
        }
    }

    private val tabs = arrayListOf("审批中", "审批通过", "审批拒绝")
    private val fragments = arrayListOf(
        MyContractChildFragment.getInstance(1),
        MyContractChildFragment.getInstance(2),
        MyContractChildFragment.getInstance(3)
    )

    override fun initView(savedInstanceState: Bundle?) {
        binding.titleBar.title = "我的合同"
        binding.titleBar.leftImageView().click { finish() }

        val adapter = ViewPagerAdapter(supportFragmentManager, lifecycle, fragments)
        binding.viewPager.adapter = adapter
        binding.slidingTabLayout.setViewPager2(binding.viewPager, tabs)

        binding.tvUpload.clickWithTrigger {
            // 上传合同
            startPageForResult<AddContractActivity>{code, data ->
                if (code == 200){
                    fragments[0].refreshData()
                }
            }
        }

    }

    override fun initData() {
    }

    override fun startObserve() {
    }

}